import { VITE_LOCALE_LANGUAGE } from '@/config'
import { createI18n } from 'vue-i18n'
import { PLATFORM } from './../config/constants'

import en from './i18n/en.json'
import zh from './i18n/zh.json'

/**
 *
 * VITE_CUSTOM_LANGUAGE 自定义语言项 翻译文件同名
 */

const languages = import.meta.glob('./i18n/*.json', { eager: true }) //获取翻译文件

const languageNameEn = `./i18n/${PLATFORM}-en.json`
const defaultLanguageNameEn = `./i18n/en.json`
const languageNameZh = `./i18n/${PLATFORM}-zh.json`
const defaultLanguageNameZh = `./i18n/zh.json`

const i18n = createI18n({
  legacy: false,
  locale: VITE_LOCALE_LANGUAGE,
  fallbackLocale: 'en',
  messages: {
    en,
    zh,
  },
})

export default i18n
